@extends('back_end.layouts.default_info')

{{-- Web site Title --}}
@section('title')
{{{ Lang::get('general.back_end.role').Lang::get('general.index') }}} :: @parent
@stop
@section('content_header')
{{{ Lang::get('general.back_end.role').Lang::get('general.index') }}}
@stop
{{-- breadcrumb --}}
@section('breadcrumb')
<li><a href="#"><i class="fa fa-dashboard"></i> {{{ Lang::get('general.back_end.home') }}}</a></li>
<li class="active">{{{ Lang::get('general.back_end.role').Lang::get('general.index') }}}</li>
@stop
{{-- Content --}}
@section('content')

<div class="box box-primary">
    <div class="box-header" style="cursor: move;">
        <i class="ion ion-clipboard"></i>

        <h3 class="box-title"></h3>

        <div class="box-tools pull-right">
            <?php echo $entries->links(); ?>
        </div>
    </div>
    <!-- /.box-header -->
    <div class="box-body">
        <ul class="todo-list ui-sortable">
            <table class="table table-hover">
                <tbody><tr>
                    <th class="col-xs-3">{{ Form::orderLink($links, '关键字', 'name') }}</th>
                    <th class="col-xs-3">{{ Form::orderLink($links, '角色名', 'display_name') }}</th>
                    <th class="col-xs-3">{{ Form::orderLink($links, '创建时间', 'created_at') }}</th>
                    <th class="col-xs-3">{{{ Lang::get('table.actions') }}}</th>
                </tr>
                @foreach ($entries as $entry)
                <tr>
                    <th class="col-xs-3">{{ $entry->name }}</th>
                    <th class="col-xs-3">{{ $entry->display_name }}</th>
                    <th class="col-xs-3">{{ $entry->created_at }}</th>
                    <th class="col-xs-3">
                        @if (Auth::user()->can('update_role'))
                        <a href="{{{ URL::action('BackRoleController@doUpdate', $entry->id) }}}" class="iframe btn btn-xs btn-default"><i class="fa fa-edit"></i> {{{ Lang::get('button.edit') }}}</a>
                        @elseif (Auth::user()->can('show_role'))
                        <a href="{{{ URL::action('BackRoleController@doUpdate', $entry->id) }}}" class="iframe btn btn-xs btn-default"><i class="fa fa-eye"></i> {{{ Lang::get('button.view') }}}</a>
                        @endif
                        @if (Auth::user()->can('delete_role'))
                        <a href="#deleteModal" data-id="{{ $entry->id }}" data-toggle="modal" class="iframe btn btn-xs btn-danger"><i class="fa fa-trash-o"></i> {{{ Lang::get('button.delete') }}}</a>
                        @endif
                    </th>
                </tr>
                @endforeach
                </tbody></table>

        </ul>
    </div>
    <!-- /.box-body -->
    <div class="box-footer clearfix no-border">
        @if (Auth::user()->can('create_role'))
        <a href="{{{ URL::to('back_end/roles/create') }}}" class="btn btn-default pull-right"><i class="fa fa-plus"></i><i class="icon-plus-sign"></i> {{{ Lang::get('button.create') }}}</a>
        @endif
    </div>
</div>

<!-- Modal -->
<div id="deleteModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h3 id="myModalLabel">确认删除</h3>
            </div>
            <div class="modal-body">
                <p>确认删除这条信息?</p>
            </div>
            <div class="modal-footer">
                <form id="deleteForm" class="form-horizontal" method="post" action="" autocomplete="off">
                    <!-- CSRF Token -->
                    <input type="hidden" name="_token" value="{{{ csrf_token() }}}" />
                    <input type="hidden" name="id" value="" />
                    <button class="btn" data-dismiss="modal" aria-hidden="true">{{{ Lang::get('button.cancel') }}}</button>
                    <button type="submit" class="btn btn-primary">{{{ Lang::get('button.ok') }}}</button>
                </form>
            </div>
        </div>
    </div>
</div>
<!-- Modal End -->
@stop

{{-- Scripts --}}
@section('scripts')
<script type="text/javascript">
    var deleteAction = "{{ URL::to('back_end/roles/delete') }}";
    $('a[data-toggle="modal"]').click(function(){
        if(deleteAction){
            $('form#deleteForm').attr('action',  deleteAction + '/' + $(this).attr('data-id'));
            $('form#deleteForm input[name="id"]').attr('value',  $(this).attr('data-id'));
        }
    });
</script>
@stop
